package entities;

/**
 * @author Omri Barda		039725890 
 * @author Amit Joseph		034608547
 * @author Gilad Shpigel  	300162393
 * @author Elad Elbaz		040539959
 * @version June 2012
 */

import java.io.Serializable;
import java.util.Date;

public class ExtractedExam implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * LOCK statuses & errors of exams
	 */
	final public static int STATUS_TIMESUP = 2;
	final public static int STATUS_LECTURERLOCK = 1;
	final public static int STATUS_ACTIVE = 0;
	final public static String ERROR = "9999";
	final public static String ERROR_EXAM_ALREADY_TOOK_PLACE = "9998";

	private int examID;
	private int CourseID;
	private int SubjectID;
	private String examCode;
	private Date examExtractDate;
	private Date examDurationTime;
	private Date examExtantionDuration;
	private int lecturerID; // the lecturer that built the exam
	private int CreatorID; // the lecturer that extracted the exam
	private int lockedExam;
	private String examLecturerInstructions;
	private String examStudentInstructions;

	/**
	 * Constructor
	 * 
	 * @param examID
	 * @param examCode
	 * @param examExtractDate
	 * @param examDurationTime
	 * @param lecturerID
	 * @param lockedExam
	 */
	public ExtractedExam(int examID, String examCode, Date examExtractDate,
			Date examDurationTime, int lecturerID, int lockedExam) {
		super();
		this.examID = examID;
		this.examCode = examCode;
		this.examExtractDate = examExtractDate;
		this.examDurationTime = examDurationTime;
		this.lecturerID = lecturerID;
		this.lockedExam = lockedExam;
	}

	/**
	 * Constructor
	 * 
	 * @param examID
	 * @param examCode
	 * @param examExtractDate
	 * @param examDurationTime
	 * @param lecturerID
	 */
	public ExtractedExam(int examID, String examCode, Date examExtractDate,
			Date examDurationTime, int lecturerID) {
		super();
		this.examID = examID;
		this.examCode = examCode;
		this.examExtractDate = examExtractDate;
		this.examDurationTime = examDurationTime;
		this.lecturerID = lecturerID;
		this.lockedExam = STATUS_ACTIVE;
	}

	/**
	 * empty Constructor
	 */
	public ExtractedExam() {

	}

	public void ChangeExamDurationTimeRequest() {

	}

	// ------------------
	// Setters & Getters
	// ------------------
	/**
	 * 
	 * @return the exam ID
	 */
	public int getExamID() {
		return examID;
	}

	/**
	 * 
	 * @param examID
	 * @return whether the ID is legal
	 */
	public Boolean setExamID(Integer examID) {
		if ((examID > 99) && (examID <= 999999)) {
			this.examID = new Integer(examID.intValue() % 100);
			this.setCourseID(new Integer((examID.intValue() / 100) % 100));
			this.setSubjectID(new Integer(examID.intValue() / 10000));
		} else if ((examID >= 0) && (examID < 100))
			this.examID = examID;
		else
			return false;
		return true;
	}

	/**
	 * 
	 * @param stdinst
	 *            the exam instructions for student
	 */
	public void setExamStudentInstructions(String stdinst) {
		examStudentInstructions = stdinst;
	}

	/**
	 * 
	 * @return instructions for the studentS
	 */
	public String getExamStudentInstructions() {
		return examStudentInstructions;
	}

	/**
	 * 
	 * @return the exam code
	 */
	public String getExamCode() {
		return examCode;
	}

	/**
	 * 
	 * @param examCode
	 *            of the exam
	 */
	public void setExamCode(String examCode) {
		this.examCode = examCode;
	}

	/**
	 * 
	 * @return the exam extract date
	 */
	public Date getExamExtractDate() {
		return examExtractDate;
	}

	/**
	 * 
	 * @param examExtractDate
	 *            of the exam
	 */
	public void setExamExtractDate(Date examExtractDate) {
		this.examExtractDate = examExtractDate;
	}

	/**
	 * 
	 * @return the exam duration time
	 */
	public Date getExamDurationTime() {
		return examDurationTime;
	}

	/**
	 * 
	 * @param examDurationTime
	 *            of the exam
	 */
	public void setExamDurationTime(Date examDurationTime) {
		this.examDurationTime = examDurationTime;
	}

	/**
	 * 
	 * @return the lecturer ID
	 */
	public int getLecturerID() {
		return lecturerID;
	}

	/**
	 * 
	 * @param lecturerID
	 *            of the exam
	 */
	public void setLecturerID(int lecturerID) {
		this.lecturerID = lecturerID;
	}

	/**
	 * 
	 * @return exam lock status
	 */
	public int getLockedExam() {
		return lockedExam;
	}

	/**
	 * lock exam due to time up
	 */
	public void timedLockExam() {
		this.lockedExam = STATUS_TIMESUP;
	}

	/**
	 * lock exam due to lecturer will
	 */
	public void lockExam() {
		this.lockedExam = STATUS_LECTURERLOCK;
	}

	/**
	 * unlock the exam
	 */
	public void unlockExam() {
		this.lockedExam = STATUS_ACTIVE;
	}

	/**
	 * 
	 * @return the exam's course ID
	 */
	public int getCourseID() {
		return CourseID;
	}

	/**
	 * 
	 * @param courseID
	 *            of the exam
	 */
	public void setCourseID(int courseID) {
		CourseID = courseID;
	}

	/**
	 * 
	 * @return the exam's subject ID
	 */
	public int getSubjectID() {
		return SubjectID;
	}

	/**
	 * 
	 * @param subjectID
	 *            of the exam
	 */
	public void setSubjectID(int subjectID) {
		SubjectID = subjectID;
	}

	/**
	 * 
	 * @return creator ID of the exam
	 */
	public int getCreatorID() {
		return CreatorID;
	}

	/**
	 * 
	 * @param creatorID
	 *            of the exam
	 */
	public void setCreatorID(int creatorID) {
		CreatorID = creatorID;
	}

	/**
	 * @return the examLecturerInstructions
	 */
	public String getExamLecturerInstructions() {
		return examLecturerInstructions;
	}

	/**
	 * @param examLecturerInstructions
	 *            the examLecturerInstructions to set
	 */
	public void setExamLecturerInstructions(String examLecturerInstructions) {
		this.examLecturerInstructions = examLecturerInstructions;
	}

	/**
	 * @return the examExtantionDuration
	 */
	public Date getExamExtantionDuration() {
		return examExtantionDuration;
	}

	/**
	 * @param examExtantionDuration the examExtantionDuration to set
	 */
	public void setExamExtantionDuration(Date examExtantionDuration) {
		this.examExtantionDuration = examExtantionDuration;
	}

}
